import 'dart:async';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:my_app/base/utils/jd_log.dart';
import 'package:my_app/modules/config/app_init_config.dart';

import 'modules/navigator/splash_page.dart';
import 'pre_init.dart';

void main() {
  initApplication() {
    return PreInit(
      initCompleteCallback: (packageInfo) {
        //启动前的配置, 不重要的可以延时初始化
        Map theMap = Map<String, dynamic>.from(packageInfo);
        AppInitConfig.instance.initConfig();
      },
      homePage: (BuildContext context) {
        return const SplashPage();
        // if (kDebugMode) {
        //   // 设置代理
        //   return const DevProxyPage();
        // } else {
        //   return const SplashPage();
        // }
      },
    );
  }

  runZonedGuarded(() {
    jdLog('runApp-----');
    runApp(initApplication.call());
  }, (error, stackTrace) {
    jdLog(
        'runZonedGuarded:error--->  ${error.toString()}  stackTrace---> ${stackTrace.toString()}');
    if (kReleaseMode) {
      // FlutterBuglyPlugin.reportException(
      //     exceptionName: error.toString(), reason: stackTrace.toString());
    }
  });
}
